export default {
    state: {
        messageGroup: {		
            // messageClass: 'success',
            // message: 'Test',
            messageClass: '',
            message: '',
            timeoutEvent: null,
        }
    },
    getters: {
        messages: (state) => {
            return state.messageGroup;
        }
    },
    mutations: {
        addMessage(state, {message, messageClass}) {
            state.messageGroup = {
                messageClass,
                message
            }
    
            if (state.timeoutEvent) {
                clearTimeout(state.timeoutEvent);
            }
            state.timeoutEvent = setTimeout(function() {
                state.messageGroup = {
                    messageClass: '',
                    message: ''
                }
            }, 5000);
        },
        clearMessage(state) {
            state.messageGroup = {
				messageClass: '',
				message: ''
			}
        }
    },
    actions: {
        addMessageActions(context, obj) {
            context.commit('addMessage',obj);
        },
        clearMessageActions(context) {
            context.commit('clearMessage');
        }
    },
    modules: {
        
    }
}
